package com.example.computer_exam_training_sys.controller;

import com.example.computer_exam_training_sys.entity.Knowledge;
import com.example.computer_exam_training_sys.service.KnowledgeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/api/knowledge")
public class KnowledgeController {

    @Autowired
    private KnowledgeService knowledgeService;

    @GetMapping("/tree")
    public ResponseEntity<List<Knowledge>> getKnowledgeTree(@RequestParam("courseId") Long courseId) {
        List<Knowledge> tree = knowledgeService.getKnowledgeTree(courseId);
        return ResponseEntity.ok(tree);
    }
}